<template>
  <div class="sticky-digitizing" :class="{ active }">
    <div class="update-top">
      <div class="inner">
        <div class="update-file">
          <img src="../../../assets/images/home/update.png" alt="update-file" />
          <div class="update-btn">
            <span>文件夹上传</span>
            <em></em>
          </div>
        </div>
      </div>
    </div>
    <div class="update-bottom">
      <div class="left">
        <ul>
          <li>
            <img src="../../../assets/images/home/dir.png" alt="progress" />
            <div class="progress"></div>
          </li>
          <li>
            <img class="ac" src="../../../assets/images/home/word-file.png" alt="progress" />
            <div class="progress"></div>
          </li>
          <li>
            <img class="ac" src="../../../assets/images/home/word-file.png" alt="progress" />
            <div class="progress"></div>
          </li>
        </ul>
        <div class="file">
          <img src="../../../assets/images/home/dir01.svg" alt="file" />
          <img src="../../../assets/images/home/dir02.svg" alt="file" />
          <img src="../../../assets/images/home/dir03.svg" alt="file" />
        </div>
      </div>
      <div class="btn">
        权限管理
        <ul>
          <li>可管理</li>
          <li>可编辑</li>
          <li>可查看下载</li>
          <li>仅查看</li>
        </ul>
      </div>
    </div>
  </div>
</template>

<script setup lang="ts">
import { onMounted, ref } from 'vue'

const active = ref<boolean>(false)

onMounted(() => {
  setTimeout(() => {
    active.value = true
  })
})
</script>

<style scoped lang="scss">
@import '@/assets/scss/base.scss';

@keyframes digitizing-select {
  0% {
    background-color: #fff;
  }
  50% {
    background-color: #e9f6ff;
  }
  100% {
    background-color: #fff;
  }
}

@keyframes digitizing-close {
  0% {
    transform: scaleY(0);
  }
  10% {
    transform: scaleY(1);
  }
  90% {
    transform: scaleY(1);
  }
  100% {
    transform: scaleY(0);
  }
}

.sticky-digitizing {
  position: absolute;
  right: 50px;
  display: flex;
  justify-content: flex-end;
  align-items: center;
  flex-direction: column;

  &.active {
    .left ul li {
      &:first-of-type {
        > .progress {
          transition: all 1s 0.3s;
          background-color: #2185fd;
          width: 344px !important;
        }
      }
    }

    .update-bottom > .btn > ul {
      animation: digitizing-close 3s 1s forwards !important;

      > li {
        @for $i from 1 through 4 {
          &:nth-of-type(#{$i}) {
            animation: digitizing-select 1s 0.5s * $i;
          }
        }
      }
    }

    .update-bottom .file {
      > img {
        @for $i from 1 through 3 {
          &:nth-of-type(#{$i}) {
            opacity: 1;
            transition: all 1s 0.3s + ($i * 0.1s);
            transform: scale(1);
          }
        }
      }
    }
  }

  .update-top {
    width: 592px;
    height: 249px;
    background: linear-gradient(0deg, #4b84fb 0%, #205fe0 100%);
    border-radius: 20px 20px 0 0;
    padding: 30px 36px 0 32px;
    box-sizing: border-box;

    > .inner {
      height: 100%;
      background-color: rgba(255, 255, 255, 0.05);
      border: 1px solid rgba(255, 255, 255, 0.24);
      border-radius: 20px 20px 0 0;

      > .update-file {
        width: calc(100% - 21px * 2);
        height: 160px;
        box-sizing: border-box;
        background-color: #ffffff;
        border-radius: 12px;
        margin: 22px 21px 0 21px;
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;

        > img {
          height: 42px;
          object-fit: contain;
        }

        > .update-btn {
          margin-top: 20px;
          width: 90px;
          min-width: 90px;
          height: 30px;
          min-height: 30px;
          color: #fff;
          display: flex;
          align-items: center;

          > span {
            font-size: 10px;
            display: inline-flex;
            width: 65px;
            height: 100%;
            justify-content: center;
            align-items: center;
            background-color: #4b9fff;
            border-radius: 4px 0 0 4px;
          }

          > em {
            display: inline-block;
            width: 25px;
            height: 100%;
            background-color: #1181ff;
            border-radius: 0 4px 4px 0;
          }
        }
      }
    }
  }

  .update-bottom {
    width: 593px;
    height: 336px;
    background: linear-gradient(180deg, #ffffff 0%, rgba(255, 255, 255, 0) 100%);
    border-radius: 0 0 20px 20px;
    box-sizing: border-box;
    padding: 25px 36px 0;
    display: flex;
    justify-content: space-between;

    > .left {
      width: 390px;

      > ul {
        > li {
          margin-bottom: 26px;
          display: flex;
          align-items: center;

          &:first-of-type {
            > .progress {
              width: 0;
            }
          }

          > img {
            width: 30px;
            height: 30px;
            object-fit: contain;
            margin-right: 14px;

            &.ac {
              height: 23px;
            }
          }

          > .progress {
            width: 344px;
            height: 14px;
            border-radius: 7px;
            background-color: #e4f3f9;
            transition: all 1s 0.3s;
          }
        }
      }

      > .file {
        > img {
          opacity: 0;
          width: 82px;
          height: 82px;
          object-fit: contain;
          transform-origin: right bottom;
          transform: scale(0);
        }
      }
    }

    > .btn {
      display: flex;
      justify-content: center;
      align-items: center;
      font-size: 14px;
      font-weight: 400;
      color: #ffffff;
      width: 80px;
      height: 35px;
      background: #2185fd;
      border-radius: 6px;
      position: relative;

      > ul {
        transform-origin: center top;
        transform: scaleY(0);
        position: absolute;
        right: 0;
        top: 100%;
        background-color: #fff;
        width: 174px;
        border-radius: 10px;
        overflow: hidden;
        transition: all 1s;

        > li {
          padding-left: 21px;
          height: 44px;
          line-height: 44px;
          font-size: 14px;
          font-weight: 400;
          color: #324153;
          cursor: pointer;
        }
      }
    }
  }
}
</style>
